package com.ehotting.edsta.circuitDesign.service.impl;



import com.ehotting.edsta.circuitDesign.domain.EsSceneParam;
import com.ehotting.edsta.circuitDesign.mapper.EsSceneParamMapper;
import com.ehotting.edsta.circuitDesign.service.IEsSceneParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 输入场景参数Service业务层处理
 * 
 * @author edsta
 * @date 2023-05-05
 */
@Service
public class EsSceneParamServiceImpl implements IEsSceneParamService
{
    @Autowired
    private EsSceneParamMapper esSceneParamMapper;

    /**
     * 查询输入场景参数
     * 
     * @param id 输入场景参数主键
     * @return 输入场景参数
     */
    @Override
    public EsSceneParam selectEsSceneParamById(Long id)
    {
        return esSceneParamMapper.selectEsSceneParamById(id);
    }

    /**
     * 查询输入场景参数列表
     * 
     * @param esSceneParam 输入场景参数
     * @return 输入场景参数
     */
    @Override
    public List<EsSceneParam> selectEsSceneParamList(EsSceneParam esSceneParam)
    {
        return esSceneParamMapper.selectEsSceneParamList(esSceneParam);
    }

    /**
     * 新增输入场景参数
     * 
     * @param esSceneParam 输入场景参数
     * @return 结果
     */
    @Override
    public int insertEsSceneParam(EsSceneParam esSceneParam)
    {
        return esSceneParamMapper.insertEsSceneParam(esSceneParam);
    }

    /**
     * 修改输入场景参数
     * 
     * @param esSceneParam 输入场景参数
     * @return 结果
     */
    @Override
    public int updateEsSceneParam(EsSceneParam esSceneParam)
    {
        return esSceneParamMapper.updateEsSceneParam(esSceneParam);
    }

    /**
     * 批量删除输入场景参数
     * 
     * @param ids 需要删除的输入场景参数主键
     * @return 结果
     */
    @Override
    public int deleteEsSceneParamByIds(Long[] ids)
    {
        return esSceneParamMapper.deleteEsSceneParamByIds(ids);
    }

    /**
     * 删除输入场景参数信息
     * 
     * @param id 输入场景参数主键
     * @return 结果
     */
    @Override
    public int deleteEsSceneParamById(Long id)
    {
        return esSceneParamMapper.deleteEsSceneParamById(id);
    }


    @Override
    public List<EsSceneParam> findBySceneId(Long sceneId) {
        EsSceneParam param = new EsSceneParam();
        param.setCircuitId(sceneId);
        return selectEsSceneParamList(param);
    }

    public List<String> findCodeListBySceneId(Long sceneId){
        List<EsSceneParam> outputParamList =  this.findBySceneId(sceneId);
        List<String> keyList = outputParamList.stream().map(t->{
            return t.getCode();
        }).collect(Collectors.toList());
        return keyList;
    }
}
